-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: enabling safe functions in expression engine #5403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
allowing toLowerCase(), replace(), and split() to be used in the expression editor. https://discord.com/channels/955905230107738152/1418928616648998992/1419623805541814393
My only wish is that we would support the entire js there and not a few functions, because:
|
I'd love webstudio to support the entire js in the expression editor! |
That's a fair point. A random list of functions is confusing, and you're right, people will always wonder why one thing works and another doesn't. The problem with allowing everything is the security risk, right? Stuff like So what if we set a clear rule for what's allowed? We could support all the standard methods on primitives (Strings, Arrays, etc.) as long as they don't mutate the original data. That way, it feels like you're just writing JavaScript for data manipulation. Methods like My PR for What do you think? I'm happy to expand the PR to include more of these "safe" methods if you agree on this as the general rule. |
…y methods This pull request enhances the expression engine to support a curated list of safe, non-mutating methods on the String and Array prototypes.
added optional chaining and additional tests.
Description
allowing toLowerCase(), replace(), and split() to be used in the expression editor.
Real life use-case explained in the discord message.
https://discord.com/channels/955905230107738152/1418928616648998992/1419623805541814393
Steps for reproduction
-> validation check bypass
Code Review
Before requesting a review
Before merging
.env
file